/**
 * 系统配置文件
 * User:lifuyuan
 * date:2018-05-07
 * To change this template use File | Setting | File Template
 *      系统配置文件
*/
const currentDir = __dirname.replace(/\\/g,'/');
let lastIndex = currentDir.lastIndexOf('/');
/**
 * 网站根目录
 * @type{String}
*/
exports.ROOT_PATH = currentDir.slice(0,lastIndex);
/**
 * redis库配置
 * @type {{port:string,host:string,options:{connect_timeout:string}}}
 * 
*/
exports.redisConfig = {
    'host':'',
    'port':'6379',
    'connect_timeout':8000
};
//mongodb://user:pass@localhost:Port/database
exports.mongodbConfig = "mongodb://localhost/zillaInstant";
/**
 * mongodb库配置:原生驱动
 * @type{{host:string,port:string,options:{auto_reconnect:boolean,poolSize:number},datdabase:string}}
 * 
 * exports.mongodbConfig = {
 *  'host':'',
 *  'port':'27017',
 *  'options':{
 *      'auto_reconnect':true,
 *      'poolSize':10   
 *  }
 * }
*/
/**
 * MODEL文件路径
 * @type {string}
 * 
*/
exports.APP_ID = "43ea5ef81c2e036a93de068f7dd739be";
exports.APP_SECRET = "ab3194ab-c4c9-4b1f-9a99-5a625bae2c60";

/**
 * 
 * zookeeper cli 
 * @type {Object}
 * 
*/
exports.zookeeperConf = {
    'connectionString':'',
    'options':{
        sessionTimeout:10000,
        spinDelay:3000,
        retries:1
    },
    'sessionPath':'/instant/session',
    'reouterPath':'/instant/router'
}

/**
 * 本地真实网络
 * [os description]
 * @type {[type]}
 * 
*/
const os = require('os');
exports.hardware = {
    'networkInterfaces':os.networkInterfaces,
    'insternetFace':function(){
        let result = [];
        let objs = this.networkInterfaces();
        delete objs.lo0;//排除回环地址
        for(let obj in objs){
            if(objs.hasOwnProperty(obj) && Array.isArray(objs[obj])){
                result.push(objs[obj].map((eth)=>{
                    return eth.address
                }).filter((address)=>{
                    return (address !== '127.0.0.1' ) && (address.indexOf('::') === -1) && (address.indexOf('10.') && (address.indexOf('192.') === -1) && (address.indexOf('172.') === -1));
                }))
            }
        }
        return result;
    }
}
/**
 * log 文件夹路径 pm2替换
 * @type {string}
*/

//exorts.LOG_PATH = this.ROOT_PATH + '/log/';